<form data-bv-feedbackicons-validating="glyphicon glyphicon-refresh" data-bv-feedbackicons-invalid="glyphicon glyphicon-remove" data-bv-feedbackicons-valid="glyphicon glyphicon-ok" data-bv-message="值不能为空" class="form-horizontal bv-form" method="post" id="TaskOrderForm" novalidate>
{if $task['task_mode']==2}

<div class="row">
    <div class="col-md-6">
         <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right">报价 (元)</label>
            <div class="col-sm-10">
                 <input type="text" class="form-control" placeholder="请输入您的报价" id="OrderOffer" name="offer" maxlength="5">
            </div>
        </div>
        <div class="horizontal-space"></div>
    </div>
    <div class="col-md-6">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right">时间 (天)</label>
            <div class="col-sm-10">
                 <input type="text" class="form-control" placeholder="请输入您的工作时间" id="OrderTime" name="time" maxlength="2">
            </div>
        </div>
        <div class="horizontal-space"></div>
    </div>
</div>
                                                    
{/if}
                                          
 {template Public:Page:umeditor}
<textarea id="Content"  name="content"  style="height:200px;width:100%">{echo $draft['content']}</textarea>
  
  <div class="col-pt-10">
    <button class="btn btn-success" type="submit">投 稿</button>
  </div>

  <input type="hidden" name="datatype" value="json"/>
  <input type="hidden" name="Submit" value="true"/>
  <input type="hidden" name="id" value="{echo $id}"/>
  <input type="hidden" name="oid" value="{echo intval($oid)}"/>

</form>



<!--Page Related Scripts-->
<script src="{echo AURL}/js/validation/bootstrapValidator.js"></script>

<script>
{if $task['task_mode']==2}
var taskmode=2;
{else}
var taskmode=1;
{/if}
        $(document).ready(function () {
			
			 var um = UM.getEditor('Content');
			 
			 um.addListener("contentChange",function(){
				if(UM.getEditor('Content').hasContents()){
					$('#TaskOrderForm button[type="submit"]').attr('disabled',false);
				}
			 });
			 

 		  $('#TaskOrderForm').bootstrapValidator({
                excluded: [':disabled'],
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                submitHandler: function (form) {
				var ordertime=orderoffer=0;
				if(taskmode==2){
					orderoffer=parseInt($('#OrderOffer').val());
					if(isNaN(orderoffer)){
						 bootbox.alert({ 
							size: 'small',
							message: "请用数字填写报价！"
						 })
						 return false; 
					}
					
					ordertime=parseInt($('#OrderTime').val());
					if(isNaN(ordertime)){
						 bootbox.alert({ 
							size: 'small',
							message: "请用数字填写时间！"
						 })
						 return false; 
					}
				}
					
				 if(!UM.getEditor('Content').hasContents()){
					 bootbox.alert({ 
						size: 'small',
						message: "请填写投稿内容！"
					 })
					 return false; 
				 }

				  $.post('{echo U("/post/task/postdraft/id/".$this->id)}',$("#TaskOrderForm").serialize(), function(json) {
					
					  	$('.bootbox').PhpappProgress({json:json});

				 		return true;
					
				  }, 'json');
				  

				 bootbox.dialog({
					 message: '<div class="progress progress-striped active"><div style="width: 1%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="20" role="progressbar" class="progress-bar progress-bar-info"><span>0%</span></div></div>',
					 title: '<i class="icon fa fa-retweet"></i> 提交中',
					 closeButton: false
				 }).PhpappProgress({time:1000});
			 
				  return false; 
				 
                } 
			
            }) 

        });
	   


    </script>
    